import { HOST } from "../config.js";
import MyAjax from "../util/MyAjax.js";
export const ajax = new MyAjax(HOST + "/api");

export default {
  top: {
    top1: document.querySelector(".top1"),
    switch: document.querySelector(".switch"),
    topes1: document.querySelector(".topes1") as HTMLElement,
    heat: document.querySelector(".switch")?.children[1],
    time: document.querySelector(".switch")?.children[2],
    gift: document.querySelector(".switch")?.children[3],
    position: document.querySelector(".position"),
  },
  content: {
    content: dom("#content"),
  },
  user: {
    imgipt: dom("#file"),
    userImg: dom(".userImg"),
    mubu: dom("#mubu"),
    registry: dom("#mubu>.registry"),
    mubuevent: {
      islogin: dom(".islogin"),
      breaklogin: dom(".breaklogin"),
      toregistry: dom(".toRegistry"),
      tologin: dom(".toLogin"),
      nickNamemodule: dom(".nickNamemodule"),
      namemodule: dom(".namemodule"),
      pwdmodule: dom(".pwdmodule"),
      ts: dom(".pppp"),
      ipt: {
        nickname: dom("#nickName"),
        name: dom("#name"),
        pwd: dom("#pwd"),
      },
      loginbtn: dom(".loginbtn"),
      registrybtn: dom(".registrybtn"),
      chongzhi: dom(".chongzhi"),
    },
    nickname: dom(".userNickName"),
    name: dom(".userName"),
    imgurl: dom(".imgurl"),
    articlecount: dom(".articleCount"),
    browescount: dom(".browesCount"),
    commentecount: dom(".commentCount"),
  },
  herder: {
    findtitleipt: dom(".findTitleipt"),
    findtitlebtn: dom(".findTitlebtn"),
  },
  index: {
    ul: dom(".ul"),
    indexAll: document.querySelectorAll(".ul>li"),
    index: dom(".index"),
    article: dom(".article"),
    about: dom(".about"),
    comment: dom(".comment"),
    shuoshuo: dom(".shuoshuo"),
    andmi: dom(".andmi"),
  },
};

function dom(ele: string): HTMLElement {
  return document.querySelector(ele) as HTMLElement;
}

export function domg(ele: string): HTMLElement {
  return document.querySelector(ele) as HTMLElement;
}
